package com.ygo.feihua.adapter;
import android.content.*;
import android.view.*;
import android.widget.*;
import com.ygo.feihua.BmobTable.*;
import java.util.*;
import com.ygo.feihua.*;
import android.view.ViewGroup.*;

public class ZhutiListAdapter extends BaseAdapter
{

	private Context context;
	private List<Zhuti> data;
	private ViewHolder vh;
	private Gongju gj;
	
	public ZhutiListAdapter(Context context,List<Zhuti> data){
		this.context=context;
		this.data=data;
		gj=Gongju.getdx(context);
	}
	
	class ViewHolder{
		ImageView zt_image;
		TextView zt_name;	
	}
	
	@Override
	public int getCount()
	{
		// TODO: Implement this method
		return data.size();
	}

	@Override
	public Object getItem(int p1)
	{
		// TODO: Implement this method
		return data.get(p1);
	}

	@Override
	public long getItemId(int p1)
	{
		// TODO: Implement this method
		return p1;
	}

	@Override
	public View getView(int position, View p2, ViewGroup p3)
	{
		if(p2==null){
			p2=LayoutInflater.from(context).inflate(R.layout.item_zhuti_list,null);
			vh=new ViewHolder();
			vh.zt_name=(TextView) p2.findViewById(R.id.zt_name);
			vh.zt_image=(ImageView) p2.findViewById(R.id.zt_image);
			
			// TODO: Implement this method				
			p2.setTag(vh);
		}else{
			vh=(ZhutiListAdapter.ViewHolder) p2.getTag();
		}
		Zhuti zt=data.get(position);
		gj.tuxian(zt.getzttb(),vh.zt_image);
		vh.zt_name.setText(zt.getztname());
		
		// TODO: Implement this method
		return p2;
	}
	
}
